<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare(strict_types=1);

namespace LhpAmis\thinkphp\Provider;

use think\db\exception\DbException as Exception;
use think\Paginator;

/**
 * 数据查询基础类
 */
abstract class BaseQuery extends \think\db\BaseQuery
{


    /**
     * 分页查询
     * @access public
     * @param int|array $listRows 每页数量 数组表示配置参数
     * @param int|bool  $simple   是否简洁模式或者总记录数
     * @return Paginator
     * @throws Exception
     */
    public function paginate($listRows = null, $simple = false): Paginator
    {
        if ($listRows = null) {
            $listRows = request()->param('list_rows', null);
            // dump($listRows);
        }

        return  parent::paginate($listRows, $simple);

    }

    /**
     * 根据数字类型字段进行分页查询（大数据）
     * @access public
     * @param int|array $listRows 每页数量或者分页配置
     * @param string    $key      分页索引键
     * @param string    $sort     索引键排序 asc|desc
     * @return Paginator
     * @throws Exception
     */
    public function paginateX($listRows = null, string $key = null, string $sort = null): Paginator
    {
        if ($listRows = null) {
            $listRows = request()->param('list_rows', null);
        }
        return  parent::paginateX($listRows, $key, $sort);

    }
}
